<!-- 健康评测 -->
<script lang="ts" setup>
definePageMeta({
  layout: 'frame',
})
// checkLogin()
const route = useRoute()
const router = useRouter()
const webUrl = route.query.webUrl as string

const url = computed(() => {
  return webUrl ? decodeURIComponent(webUrl) : `http://139.196.111.15:9102/health/#/pages/evaluation/evaluation`
})
const title = computed(() => '健康评测')
const routePath = computed(() => {
  if (route.query.title) {
    if (route.query.from === 'home') {
      return [{ name: '首页', type: 'home' }, { name: route.query.title }]
    }
    return [{ name: '首页', type: 'home' }, { name: '健康评测', path: '/peopleHealth/evaluation' }, { name: route.query.title }]
  }
  else {
    return [{ name: '首页', type: 'home' }, { name: '健康评测' }]
  }
})
function back() {
  router.go(-1)
}
const isQuestionnnaire = computed(() => {
  return route.query.webUrl?.includes(encodeURIComponent('/questionnaire/survey/survey'))
})
function toAnalysis() {
  const webUrl = decodeURIComponent(route.query.webUrl)
  const regex = /activity_no=([^&]+)/
  const match = webUrl.match(regex)
  const activity_no = match ? match[1] : ''
  if (!activity_no) {
    console.log('没有找到activity_no')
  }
  else {
    navigateTo({
      path: '/peopleHealth/surveyAnalysis',
      query: {
        no: activity_no,
        title: route.query.title,
        status: route.query.status,
      },
    })
  }
}
</script>

<template>
  <div class="relative py-50px">
    <div class="absolute left-0 top-0 z--1 hidden h-570px w-full bg-[linear-gradient(180deg,_rgba(39,162,128,1)_0%,rgba(39,162,128,0)_100%)] md:block" />
    <div class="no-repeat absolute left-0 top-0 z--1 hidden h-400px w-full bg-[url(/img/bg-top.png)] bg-cover md:block" />
    <CommonPageContainer :path="routePath" :title="title">
      <div class="my-20px bg-#F7F9FD p-30px">
        <div class="mb-20px flex items-center">
          <div
            class="m-l--50px h-40px w-40px cursor-pointer rounded-6px bg-[linear-gradient(159.97deg,_rgba(206,234,158,1)_-140.78%,#AC8358_89.45%)]"
            flex="~ items-center justify-center"
            title="返回"
            @click="back"
          >
            <i class="i-fa-solid:chevron-circle-left text-white" />
          </div>
          <div v-if="route.query.title" class="ml-14px text-20px text-#AC8358 font-600 line-height-30px">
            {{ route.query.title }}
          </div>
          <!-- <div v-if="isQuestionnnaire" class="flex-1 text-right">
            <button class="btn" @click="toAnalysis">
              数据分析
            </button>
          </div> -->
        </div>
        <IframeView :url="url" style="width: 100%;height: 100vh;" />
      </div>
    </CommonPageContainer>
  </div>
</template>

<style>

</style>
